#include <stdio.h>
#include <pthread.h>

void *function(void *args)
{
    printf("thread id in pthread = %lu\n", pthread_self());
    pthread_exit((void *)1);
}

int main()
{
    int i = 10;
    pthread_t tid;
    int iRet = pthread_create(&tid, NULL, &function, &i);
    if (iRet)
    {
        printf("pthread_create error: iRet=%d\n", iRet);
        return iRet;
    }
    // pthread_create创建的id和pthread_self获得的线程id一样
    printf("thread id in pthread = %lu\n", tid);
    void *retval;
    iRet = pthread_join(tid, &retval);
    if (iRet)
    {
        printf("pthread_join error: iRet=%d\n", iRet);
        return iRet;
    }
    printf("retval=%ld\n", (long)retval);
    return 0;
}
